/*    */ package blockbuster.components.appearance;
/*    */ 
/*    */ import blockbuster.BedrockSchemeJsonAdapter;
/*    */ import blockbuster.components.BedrockComponentBase;
/*    */ import blockbuster.components.IComponentParticleRender;
/*    */ import blockbuster.emitter.BedrockEmitter;
/*    */ import blockbuster.emitter.BedrockParticle;
/*    */ import blockbuster.math.molang.MolangException;
/*    */ import blockbuster.math.molang.MolangParser;
/*    */ import com.google.gson.JsonElement;
/*    */ import com.google.gson.JsonObject;
/*    */ import net.minecraft.client.renderer.BufferBuilder;
/*    */ 
/*    */ public class BedrockComponentAppearanceTinting
/*    */   extends BedrockComponentBase implements IComponentParticleRender {
/* 16 */   public Tint color = new Tint.Solid();
/*    */ 
/*    */ 
/*    */   
/*    */   public BedrockComponentBase fromJson(JsonElement elem, MolangParser parser) throws MolangException {
/* 21 */     if (!elem.isJsonObject()) return super.fromJson(elem, parser);
/*    */     
/* 23 */     JsonObject element = elem.getAsJsonObject();
/*    */     
/* 25 */     if (element.has("color")) {
/*    */       
/* 27 */       JsonElement color = element.get("color");
/*    */       
/* 29 */       if (color.isJsonArray() || color.isJsonPrimitive()) {
/*    */         
/* 31 */         this.color = Tint.parseColor(color, parser);
/*    */       }
/* 33 */       else if (color.isJsonObject()) {
/*    */         
/* 35 */         this.color = Tint.parseGradient(color.getAsJsonObject(), parser);
/*    */       } 
/*    */     } 
/*    */     
/* 39 */     return super.fromJson((JsonElement)element, parser);
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public JsonElement toJson() {
/* 45 */     JsonObject object = new JsonObject();
/* 46 */     JsonElement element = this.color.toJson();
/*    */     
/* 48 */     if (!BedrockSchemeJsonAdapter.isEmpty(element))
/*    */     {
/* 50 */       object.add("color", element);
/*    */     }
/*    */     
/* 53 */     return (JsonElement)object;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void preRender(BedrockEmitter emitter, float partialTicks) {}
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void render(BedrockEmitter emitter, BedrockParticle particle, BufferBuilder builder, float partialTicks) {
/* 65 */     renderOnScreen(particle, 0, 0, 0.0F, 0.0F);
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public void renderOnScreen(BedrockParticle particle, int x, int y, float scale, float partialTicks) {
/* 71 */     if (this.color != null) {
/*    */       
/* 73 */       this.color.compute(particle);
/*    */     }
/*    */     else {
/*    */       
/* 77 */       particle.r = particle.g = particle.b = particle.a = 1.0F;
/*    */     } 
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public void postRender(BedrockEmitter emitter, float partialTicks) {}
/*    */ 
/*    */ 
/*    */   
/*    */   public int getSortingIndex() {
/* 88 */     return -10;
/*    */   }
/*    */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\blockbuster\components\appearance\BedrockComponentAppearanceTinting.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */